let jwt = require(`jsonwebtoken`);
let config=require('../config/config');
module.exports = (name) => {
  let expiry = new Date();
  expiry.setDate(expiry.getDate() + 7); //有效期设置为七天
  const token = jwt.sign(
    {
      name: name,
      exp: parseInt(expiry.getTime() / 1000) //除以1000以后表示的是秒数
    },
    config.JWT_SECRET
  );
  console.log(token)
  return token;
};
